﻿using System;

namespace SystemWnioskujacy
{
    public class Functions
    {
        private Action[] fTab = new Action[0];

        public int Length
        {
            get
            {
                return fTab.Length;
            }
        }

        public Action this[int i]
        {
            get
            {
                return fTab[i];
            }
        }

        public void Add(Action nAction)
        {
            Action[] nTab = new Action[fTab.Length + 1];

            Array.Copy(fTab, nTab, fTab.Length);
            nTab[nTab.Length - 1] = nAction;

            fTab = nTab;
        }

        public void Remove(Action oAction)
        {
            for (int i = 0; i < fTab.Length; i++)
            {
                if (fTab[i].Equals(oAction))
                {
                    Action[] nTab = new Action[fTab.Length - 1];

                    Array.Copy(fTab, nTab, i);
                    Array.Copy(fTab, i + 1, nTab, i, fTab.Length - i - 1);

                    fTab = nTab;
                    break;
                }
            }
        }

        public void Remove(int i)
        {
            if (fTab.Length > i)
            {
                Action[] nTab = new Action[fTab.Length - 1];

                Array.Copy(fTab, nTab, i);
                Array.Copy(fTab, i + 1, nTab, i, fTab.Length - i - 1);

                fTab = nTab;
            }
        }
    }
}
